The IRA was intended as a vehicle to provide tax shelters for retirement savings for workers without pensions.
The 401K was a provision in the 1978 tax code to allow company executives some tax-preferred treatment for deferring compensation. It wasn't intended for widespread use, and was not originally intended to be a retirement savings vehicle. The 401K as we know it was created in 1980, when a Johnson & Co. lawyer asked the IRS for a ruling to apply the 401K regulations to more than just executives. The IRS decided the law as written didn't specify executives, and let them. As its use expanded, laws were changed over time to reflect it's status as a retirement vehicle.
I believe there are different contribution limits because of the difference in origins. As a tax break for the masses, the IRA had limits to reduce its cost. The 401K was envisioned as a limited impact, so could be more generous. Even now, more people have access to an IRA than have access to a 401K.