A 301 redirect is a permanent forwarding order. It tells a browser, and Google, that the page which used to be at one address now lives at another. The visitor lands on the new page without noticing, and search engines move the value of the old page across to the new one.
Why a rebuild needs them
When a site is rebuilt, the addresses usually change. What was services.php becomes /services/roof-repairs/. Every link anyone ever made to the old address, every bookmark, every result still sitting in Google, now points at nothing.
A 301 for each old address fixes all of it in one go. Without them the old results go to an error page for weeks until Google works out what happened, and the phone goes quiet in exactly the period you were hoping it would ring more.
301 or 302
A 301 is permanent and a 302 is temporary. The number matters, because a 302 tells Google to keep the old address in its index and expect the page to come back.
Use 302 only for something genuinely short lived, such as a page taken down for a fortnight. For a rebuild, a domain change or a tidied address, it is 301 every time. Google explains the distinction in its redirects and Google Search documentation.
A worked example
A roofing firm had a page at /roof-repairs-leeds.html that had been ranking for four years. The rebuild moves it to /areas/leeds/. Nobody sets a redirect.
For the next two months, everyone clicking that old Google result gets a page not found. The firm assumes the new site is worse. The new site is better, it is just not connected to the four years of history the old one earned.