This is actually a huge misconception, US K12 education is actually absolutely top-notch, but there are significant disparities among various ethnic groups that muddle the picture.
There is an organisation called PISA, that runs massive tests of high school students every 3 years(It's what the question's Pew article was referring to. PISA also provides demographic information in their data and here are the results for the US in 2018, in comparison to every other country in the test dataset, ranked from best to worst:
| Education system | Mean | Reading | Math | Science |
|------------------------- |------ |--------- |------ |--------- |
| B-S-J-Z (China) | 579 | 555 | 591 | 590 |
| Singapore | 556 | 549 | 569 | 551 |
| Asian Americans | 549 | 556 | 539 | 551 |
| Macau (China) | 542 | 525 | 558 | 544 |
| Hong Kong (China) | 531 | 524 | 551 | 517 |
| Estonia | 525 | 523 | 523 | 530 |
| European Americans | 521 | 531 | 503 | 529 |
| Japan | 520 | 504 | 527 | 529 |
| Korea, Republic of | 520 | 514 | 526 | 519 |
| Canada | 517 | 520 | 512 | 518 |
| Chinese Taipei | 517 | 503 | 531 | 516 |
| Finland | 516 | 520 | 507 | 522 |
| Poland | 513 | 512 | 516 | 511 |
| Ireland | 505 | 518 | 500 | 496 |
| Slovenia | 504 | 495 | 509 | 507 |
| United Kingdom | 504 | 504 | 502 | 505 |
| New Zealand | 503 | 506 | 494 | 508 |
| Sweden | 502 | 506 | 502 | 499 |
| Netherlands | 502 | 485 | 519 | 503 |
| Denmark | 501 | 501 | 509 | 493 |
| Germany | 500 | 498 | 500 | 503 |
| Belgium | 500 | 493 | 508 | 499 |
| Australia | 499 | 503 | 491 | 503 |
| Switzerland | 498 | 484 | 515 | 495 |
| Norway | 497 | 499 | 501 | 490 |
| Czech Republic | 495 | 490 | 499 | 497 |
| United States | 495 | 505 | 478 | 502 |
| France | 494 | 493 | 495 | 493 |
| Multi-racial Americans | 492 | 501 | 474 | 502 |
| Portugal | 492 | 492 | 492 | 492 |
| Austria | 491 | 484 | 499 | 490 |
| OECD average | 488 | 487 | 489 | 489 |
| Latvia | 487 | 479 | 496 | 487 |
| Spain | NA | NA | 481 | 483 |
| Russian Federation | 482 | 479 | 488 | 478 |
| Iceland | 481 | 474 | 495 | 475 |
| Lithuania | 480 | 476 | 481 | 482 |
| Hungary | 479 | 476 | 481 | 481 |
| Italy | 477 | 476 | 487 | 468 |
| Luxembourg | 477 | 470 | 483 | 477 |
| Belarus | 472 | 474 | 472 | 471 |
| Croatia | 472 | 479 | 464 | 472 |
| Hispanic Americans | 470 | 481 | 452 | 478 |
| Slovak Republic | 469 | 458 | 486 | 464 |
| Israel | 465 | 470 | 463 | 462 |
| Turkey | 463 | 466 | 454 | 468 |
| Ukraine | 463 | 466 | 453 | 469 |
| Malta | 459 | 448 | 472 | 457 |
| Greece | 453 | 457 | 451 | 452 |
| Serbia | 442 | 439 | 448 | 440 |
| Cyprus | 438 | 424 | 451 | 439 |
| Chile | 438 | 452 | 417 | 444 |
| African Americans | 436 | 448 | 419 | 440 |
| United Arab Emirates | 434 | 432 | 435 | 434 |
| Malaysia | 431 | 415 | 440 | 438 |
| Romania | 428 | 428 | 430 | 426 |
| Bulgaria | 427 | 420 | 436 | 424 |
| Moldova, Republic of | 424 | 424 | 421 | 428 |
| Uruguay | 424 | 427 | 418 | 426 |
| Brunei Darussalam | 423 | 408 | 430 | 431 |
| Montenegro, Republic of | 422 | 421 | 430 | 415 |
| Albania | 420 | 405 | 437 | 417 |
| Jordan | 416 | 419 | 400 | 429 |
| Mexico | 416 | 420 | 409 | 419 |
| Costa Rica | 415 | 426 | 402 | 416 |
| Qatar | 413 | 407 | 414 | 419 |
| Thailand | 413 | 393 | 419 | 426 |
| Colombia | 405 | 412 | 391 | 413 |
| Bosnia and Herzegovina | 402 | 403 | 406 | 398 |
| Kazakhstan | 402 | 387 | 423 | 397 |
| Baku (Azerbaijan) | 402 | 389 | 420 | 398 |
| Peru | 402 | 401 | 400 | 404 |
| Brazil | 400 | 413 | 384 | 404 |
| North Macedonia | 400 | 393 | 394 | 413 |
| Argentina | 395 | 402 | 379 | 404 |
| Georgia | 387 | 380 | 398 | 383 |
| Saudi Arabia | 386 | 399 | 373 | 386 |
| Indonesia | 382 | 371 | 379 | 396 |
| Lebanon | 377 | 353 | 393 | 384 |
| Morocco | 368 | 359 | 368 | 377 |
| Panama | 365 | 377 | 353 | 365 |
| Kosovo | 361 | 353 | 366 | 365 |
| Philippines | 350 | 340 | 353 | 357 |
| Dominican Republic | 334 | 342 | 325 | 336 |
As you can see, in terms of actually educating it's students, the US educates:
- It's Asian origin students better than any other Asian country other than Singapore and the BSJZ(Beijing, Shanghai, Jiangsu and Zhejiang) region of China.
- It's European origin students better than any European country other than Estonia.
- It's Hispanic origin students way better than any Latin American country.
The only African country that participated in PISA is Morocco, but since it's near the top of African countries in HDI, it's safe to say that the other African countries are at least as bad as, or much worse at educating their students than the US is at educating African Americans.
I'm not speculating upon the reasons for the group differences, because it's a white hot, radioactive potato and not relevant to the question, I'm just pointing out that the US is actually doing great at educating whichever children it has.
This is actually a classic example of Simpson's Fallacy, but mentioning group differences is understandably avoided, so every time PISA results come out, there is the same set of predictable articles lamenting the US K12 education system and they'll be the same in 2021, when the next round of PISA tests takes place.