You have to consider the timeline, the way the deal is changed through the course of the film, and his reasons why.
When the Imperials first arrive at Bespin, he is trying to protect his interests as he says to Leia when she asks him about his fears of Imperial interference.
"I've just made a deal that will keep the Empire out of here forever."
At that point, he believes the deal is simply to allow the Empire to capture Skywalker while Han, Leia, and the rest will go free.
They then understand that Vader is there and what the deal is, at that point Vader tortures Solo, something he had not told Lando about. As Lando explains to Leia, they just want to get Luke.
Then the deal changes again, with Han being frozen in Carbonite and handed over to Boba Fett, and Vader decreeing that Leia and Chewbacca be kept on Cloud City
Lando demonstrates the deal is getting out of his control when he says
"This deal is getting worse all the time."
and Vader
"I have altered the deal. Pray I don't alter it further".
Finally, a 3rd change is made with Chewbacca and Leia being taken out of Cloud City and Vader deciding to leave a garrison.
By this time, Lando realises that he has lost all control of the deal and more than likely he and his people will be arrested, enslaved, or worse by Imperial forces. He decides then to fight the Empire and escape rather than wait until it is too late to be able to do anything.
It has been suggested that he is more worried about earning money than his people, however if that where the case, he would have left quietly and not given a message informing his people to escape. In addition, this idea does not match with the character as he has been portrayed throughout the Star Wars Universe.
"Our operation is small enough not to be noticed. Which is
advantageous for everybody since our customers are anxious to avoid
attracting attention to themselves."
This does not necessarily mean he is trading with evil criminals. He could be providing supplies to anyone that the Empire does not want to have access to the resources of Bespin: rebel groups or organisations trying to supply planets being cut off by the Empire; he could well provide services that are relatively cheap for the risks involved. It would have been easier and possibly more lucrative to open his doors to the Empire and, in the same way as the Hutts, enter into an agreement with the Empire them turning a blind eye.
There is another suggestion that Lando needed to get forces in place in order to betray the Empire: he needed to buy time so repairs could be made to the Falcon and ensure that when the time came to fight back, everything was in place to do that successfully. There is no clear evidence for that other than some sources online that suggest Lando was already involved in the rebellion. These may or may not be canon, so I won't add them as fact here.