In 2017 Perez was said to be bringing in around $15 million in sponsorship (which is what Vettel is reportedly getting as a salary for 2021 with RP). Mazepin is the son of a Russian billionaire and his father was evidently considering buying Force India before Stroll's dad did the deal, so one assumes he is supporting his son at Haas into the eight figures.
As to driving for Haas, yes they have been terrible this year, but they did decent in prior years and I think this year's failure is heavily influenced by how poor Ferrari's factory team and engine is and Haas does get a fair bit of kit from them. And I think sitting out for the entire 2021 season might be more detrimental to his F1 career than being with one of the bottom teams.