Earlier in the episode, Stu explains to Louis why they had to move out of the office space:
Stu: Sutter went bankrupt two days ago, and they owed us under their contract. They're offering us their space to cover their obligations and I have to say yes by tomorrow.
Louis: You wouldn't even have those obligations, Stu, if it weren't for us.
Stu: I know that, but I can't tell my bosses I'm passing on a fortune in free rent 'cause you guys did me a solid.
So they're not relocating because they couldn't afford rent, but because they can save a lot of money by moving to another office where they don't have to pay any rent. However, to help Louis (and Harvey) out he buys enough shares to become the largest shareholder and make sure they won't get fired.