Mothballing is a technique used to get rid of ship maintenance for situations when ships are not needed at the moment but may be needed later.
Ships can be mothballed and unmothballed through the Scrap / Analyze / Mothball menu (hotkey is 'G'). There is no cost to mothball a ship, but there is a cost for unmothballing. Ships can be mothballed anywhere, but unmothballing a ship requires a shipyard or spaceyard in the same location as the ship.
Note that ships with population on board cannot be mothballed, and no error message will notify you that mothballing failed if you try this on a ship. This is a known bug.
A mothballed ship has its experience reset to 0%. The ship will have no maintenance cost while mothballed, and will also no longer contribute to the civilization's score. When unmothballed, a ship will start that round with no movement points.