Ubuntu uses APT (Advanced Package Tool) for installing, removing and managing software on the system, and in doing so it keeps a cache of previously downloaded and installed packages even after they've been uninstalled.
To save disk space the apt cache can be cleaned. This can be done in one of two ways. First will do it partially:
$ sudo apt-get autoclean
This command will remove only the outdated packages, like those superseded by a recent update, making them completely unnecessary.
This may free up some disk space, but if you want to clean out the cache in its entirety you would run:
$ sudo apt-get clean
This command will remove all of the cached packages, saving the most space. This just means that if you were to ever need a package that was cached it will simply have to be downloaded again. Depending on your connection speed and data plan this may or may not be of concern. Other than that, it is safe to do.
Perhaps noteworthy is that the apt cache resides in /var/cache/apt/archives/. You can see them if you run the ls command on that path or view it in a file manager. Manually removing packages from this directory should be safe, but with the simpler and faster methods above there's no need.