The trading deadline is the last day that major league teams can made trades without a player clearing waivers. Recently, it has become a time for teams who are out of the playoffs to dump expensive players for prospects as they rebuild their team. Also, players who are expected to become free agents are sometimes "rented" to a contender for the pennant race.
The deadline was put in place after the late-season trade of Joe Dugan that allowed the New York Yankees to win the 1922 American League pennant. During the off-season, Commissioner Landis enacted a trading deadline.
From 1923 to 1985, the trading deadline was June 15th. In 1986, it became midnight Eastern time on July 31st - since moved to 4 pm ET. Sometimes trades were not announced until August 1st as the paperwork did not reach the league office until after 11 PM on July 31.
Until 2019, trades were still possible after the deadline, but all players involved had to first clear revocable waivers. This was to ensure that no front-line players could pass through the system. However this did not work, as trades of such players after the deadline became increasingly common in the 2010s. In effect, this created a second deadline on August 31st, as this was the last day a player added to the roster could be eligible for postseason play. To counter this, the deadline was made a firm one once again in 2019, with no trades allowed to take place after July 31st.