The Sedition Act of 1798 was absolutely not a legitimate action to protect the security of the United States. It went far beyond anything that could possibly be legitimate and ended up being nothing more than a politically motivated law used to stifle dissent and political opposition.
The Sedition Act did little or nothing to increase the security of the United States. Instead, it simply outlawed political dissent. It said that anyone who said anything that might bring the United States government into disrepute could be prosecuted. It denied people the right to get together to oppose anything that the government might do. These and other similar provisions of the law had nothing to do with protecting the US from France or from England, the main sources of worry at the time. Instead, they simply made it possible for the government to prosecute those who disagreed with it.
This was not a law that helped protect US security. All it did was to prevent political dissent.