Each nation determines its own entry requirements. Countries may have signed reciprocal entry agreements (treaties) that establish different entry requirements for visitors from certain countries. Many nations require that visitors from other countries prove that they have enough money to last for their entire visit. Some may also require that visitors have a ticket to return home or an onward ticket to another country.
These requirements are sometimes waived for visitors (usually from certain countries) for short visits (30 days, for example). In practice, they’re often enforced only when border officials have reason to suspect that a visitor seeking entry may lack sufficient funds. For example, border officials may treat a scruffy backpacker walking up to a land border differently than a well-dressed businessman arriving on an international flight. Basically, countries want to deny entry to people who have little money because they may become vagrants, engage in crimes, attempt to work or immigrate illegally, or otherwise become a burden.
The U.S. State Department provides basic entry requirements for all countries. For an example of a country that may ask visitors to provide proof of sufficient funds, onward/return ticket, and lodging accommodations, check out the entry for Aruba.