The code that I linked to is for using WordPress as the authentication provider for Discourse.
The WordPress plugin also allows WordPress to be used as a DiscourseConnect client: wp-discourse/lib/sso-client at main · discourse/wp-discourse · GitHub.
I’m not sure what the motivation was for adding a custom SSO implementation to Discourse. I’m guessing there was a business case for it.
One benefit it provides is that it allows an external site to be tightly integrated with Discourse. For example, all the user attributes listed here can be synced with Discourse during the auth process: discourse/lib/discourse_connect_base.rb at 7b89fdead98606d4f47ceb0a1d240d0f6e5f589e · discourse/discourse · GitHub.
It also allows sites that aren’t configured to be OAuth2 or OpenID Connect providers to be used for authenticating users on Discourse.
The downside is that it requires adding some custom code to the auth provider site.